package com.hong.dubbo.provider;

import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Macrowang
 * @date 2019/03/01 9:57
 **/
//@ImportResource(locations = {"classpath:dubbo/dubbo_provider.xml"})
public class ProviderMain {
    public static void main(String[] args) throws Exception {
        /**
         * 启动Dubbo服务，dubbo会在启动服务时，读取classpath下一个名为dubbo.properties文件的属性值
         * dubbo.container=spring
         * #set dubbo Sping load setting xmls
         * dubbo.spring.config=classpath:dubbo_provider.xml
         * dubbo.protocol.name=dubbo
         * dubbo.protocol.port=28511
         */
       // com.alibaba.dubbo.container.Main.main(args);

        /**
         * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before
         * launch the application
         */
        System.setProperty("java.net.preferIPv4Stack", "true");

        // ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo_provider.xml"});
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        context.start();
        System.out.println("Provider started.");
        // 让程序保持不退出
        System.in.read(); // press any key to exit
    }
}